<!-- @author Shiyn/   huangmx 20200807优化-->
<template>
  <div class="top-right-btn">
    <el-row v-if="stype=='V1'">
      <el-button v-if="showSearch"  type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
      <el-button v-if="showSearch" icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      <el-button size="mini" @click="toggleSearch()" >{{showSearch ? '隐藏搜索' : '显示搜索'}}</el-button>
      <el-tooltip class="item" effect="dark" content="刷新" placement="top">
        <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
      </el-tooltip>
      <el-tooltip class="item" effect="dark" content="表单设置" placement="top" v-hasRole="['admin']" v-if="strIsNotEmpty(tabGenId)">
        <el-button size="mini" circle icon="el-icon-milk-tea" @click="drawerVisible=!drawerVisible"/>
      </el-tooltip>
    </el-row>
    <el-row v-else-if="stype=='OnlyRefresh'">
      <el-tooltip class="item" effect="dark" content="刷新" placement="top">
        <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
      </el-tooltip>
    </el-row>
    <el-row v-else>
      <el-tooltip class="item" effect="dark" :content="showSearch ? '隐藏搜索' : '显示搜索'" placement="top">
        <el-button size="mini" circle icon="el-icon-search" @click="toggleSearch()" />
      </el-tooltip>
      <el-tooltip class="item" effect="dark" content="刷新" placement="top">
        <el-button size="mini" circle icon="el-icon-refresh" @click="refresh()" />
      </el-tooltip>
    </el-row>

    <el-drawer
      title="配置与开发"
      :withHeader="false"
      :visible.sync="drawerVisible">
      <ModeQuickSet v-if="drawerVisible"
                    :tabGenId="tabGenId"
                    @close="drawerVisible=false"
                    @changeModeConfig="changeModeConfig"/>
    </el-drawer>
  </div>
</template>
<script>
import ModeQuickSet from '@/views/youshuda/base/crud/ModeQuickSet'
export default {
  name: "RightToolbar",
  components:{
    ModeQuickSet
  },
  data() {
    return {
      drawerVisible: false, //抽屉的显示标识
    };
  },
  props: {
    showSearch: {
      type: Boolean,
      default: true,
    },
    //控制按钮显示
    stype:{
      default: ''
    },
    //业务模块配置信息
    tabGenId: {
      default: ''
    }
  },

  methods: {
    //搜索
    toggleSearch() {
      this.$emit("update:showSearch", !this.showSearch);
    },
    //刷新
    refresh() {
      this.$emit("queryTable");
    },
    //查询
    handleQuery(){
      if(this.showSearch){

      }
      this.$emit("handleQuery");
    },
    //重置
    resetQuery(){
      this.$emit("resetQuery")
    },
    changeModeConfig(modeConfig){
      this.$emit("changeModeConfig",modeConfig)
    }
  },
};
</script>
